package org.sunshinebox.team.exception;

import org.sunshinebox.team.core.action.AbstractResultedAction;
import org.sunshinebox.team.core.internalization.Message;

public abstract class AbstractExceptionHandlingTemplate {
	
	public <ReturnType> ReturnType resolve(AbstractResultedAction<ReturnType> action){
		try {
			return action.actImpl();	
		} catch (MessageAwareException e) {
			handleMessage(e.getMsg());
		} catch (ProcessingException e) {
			handleProcessingException(e);
		}catch (RuntimeException e) {
			handleOtherException(e);
		}
		return null;
	}

	public abstract void handleMessage(Message message);
	public abstract void handleProcessingException(ProcessingException exception);
	public abstract void handleOtherException(RuntimeException exception);
	
}
